home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / wnos / wn941101 / global.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-07  |  7.5 KB  |  262 lines

  1. #ifndef _GLOBAL_H
  2. #define    _GLOBAL_H
  3.  
  4. #define    __CPLUSPLUS        1
  5. #undef    MDEBUG            1
  6. /* Global definitions used by every source file.
  7.  * Some may be compiler dependent.
  8.  */
  9.  
  10. #if    defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  11. #define    ANSIPROTO        1
  12. #if defined (MAXPATH)
  13. #undef MAXPATH
  14. #endif
  15. #define MAXPATH 80
  16. #endif
  17.  
  18. #ifndef    __ARGS
  19. #ifdef    ANSIPROTO
  20. #define    __ARGS(x)        x
  21. #else
  22. #define    __ARGS(x)        ()
  23. #endif
  24. #endif
  25.  
  26. #if !defined(__STDIO_H)
  27. #include <stdio.h>
  28. #endif
  29.  
  30. #if    !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  31. /* These compilers require special open modes when reading binary files.
  32.  *
  33.  * "The single most brilliant design decision in all of UNIX was the
  34.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  35.  *
  36.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  37.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  38.  */
  39. #define    READ_BINARY        "rb"
  40. #define    WRITE_BINARY    "wb"
  41. #define    APPEND_BINARY    "ab+"
  42. #define    READ_TEXT        "rt"
  43. #define    WRITE_TEXT        "wt"
  44. #define    APPEND_TEXT        "at+"
  45.  
  46. #else
  47.  
  48. #define    READ_BINARY        "r"
  49. #define    WRITE_BINARY    "w"
  50. #define    APPEND_BINARY    "a+"
  51. #define    READ_TEXT        "r"
  52. #define    WRITE_TEXT        "w"
  53. #define    APPEND_TEXT        "a+"
  54.  
  55. #endif
  56.  
  57. /* These two lines assume that your compiler's longs are 32 bits and
  58.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  59.  * but it doesn't matter if they're signed or unsigned.
  60.  */
  61. typedef long int32;                /* 32-bit signed integer */
  62. typedef unsigned short int16;    /* 16-bit unsigned integer */
  63. #define    uchar(x) ((unsigned char)(x))
  64. #define    MAXINT16 65535L            /* Largest 16-bit integer */
  65. #define    MAXINT32 4294967295L    /* Largest 32-bit integer */
  66.  
  67. #define    HASHMOD    7                /* Modulus used by hash_ip() function */
  68.  
  69. /* The "interrupt" keyword is non-standard, so make it configurable */
  70. #if    defined(__TURBOC__) && defined(MSDOS)
  71. #define    INTERRUPT    void interrupt
  72. #else
  73. #define    INTERRUPT    void
  74. #endif
  75.  
  76. /* Note that these definitions are on by default if none of the Turbo-C style
  77.  * memory model definitions are on; this avoids having to change them when
  78.  * porting to 68K environments.
  79.  */
  80. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  81. #define    LARGEDATA    1
  82. #endif
  83.  
  84. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  85. #define    LARGECODE    1
  86. #endif
  87.  
  88. /* Since not all compilers support structure assignment, the ASSIGN()
  89.  * macro is used. This controls how it's actually implemented.
  90.  */
  91. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  92. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  93. #else            /* Version for compilers that do */
  94. #define    ASSIGN(a,b)    ((a) = (b))
  95. #endif
  96.  
  97. /* Define null object pointer in case stdio.h isn't included */
  98. #ifndef    NULL
  99. /* General purpose NULL pointer */
  100. #define    NULL (void *)0
  101. #endif
  102. #define    NULLCHAR (char *)0    /* Null character pointer */
  103. #define    NULLCHARP (char **)0    /* Null character pointer pointer */
  104. #define    NULLINT    (int *)0    /* Null integer pointer */
  105. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  106. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  107. #define    NULLVIFP (INTERRUPT (*)())0
  108. #define    NULLFILE (FILE *)0    /* Null file pointer */
  109.  
  110. /* standard boolean constants */
  111. typedef enum   {
  112.    False,True
  113. }Boolean;                               /* DK5DC                        */
  114. #define FALSE 0
  115. #define TRUE 1
  116. #define NO 0
  117. #define YES 1
  118.  
  119. /* string equality shorthand */
  120. #define STREQ(x,y) (strcmp(x,y) == 0)
  121.  
  122. /* Extract a short from a long */
  123. #define    hiword(x)    ((int16)((x) >> 16))
  124. #define    loword(x)    ((int16)(x))
  125.  
  126. /* Extract a byte from a short */
  127. #define    hibyte(x)    ((unsigned char)((x) >> 8))
  128. #define    lobyte(x)    ((unsigned char)(x))
  129.  
  130. /* Extract nibbles from a byte */
  131. #define    hinibble(x)    (((x) >> 4) & 0xf)
  132. #define    lonibble(x)    ((x) & 0xf)
  133.  
  134. /* Various low-level and miscellaneous functions */
  135. unsigned long availmem __ARGS((void));
  136. int dirps __ARGS((void));
  137. int getopt __ARGS((int argc,char *argv[],char *opts));
  138. int htoi __ARGS((char *));
  139. long htol __ARGS((char *));
  140. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  141. int16 hash_ip __ARGS((int32 addr));
  142. int istate __ARGS((void));
  143. void log __ARGS((int s,char *fmt, ...));
  144. int log2 __ARGS((int16 x));
  145. void *ltop __ARGS((long));
  146. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  147. long ptol __ARGS((void *));
  148. void restore __ARGS((int int_status));
  149. void rflush __ARGS((void));
  150. void rip __ARGS((char *));
  151. char *smsg __ARGS((char *msgs[],unsigned nmsgs,unsigned n));
  152. int tprintf __ARGS((char *fmt,...));
  153. int tputs __ARGS((char *s));
  154. #if    !defined __TURBOC__
  155. char *strxdup __ARGS((const char *));
  156. #endif
  157. int wildmat __ARGS((char *s,char *p,char **argv));
  158.  
  159. #include <stdlib.h>
  160. #include <string.h>
  161.  
  162. #ifdef    AZTEC
  163. #define    rewind(fp)    fseek(fp,0L,0);
  164. #endif
  165.  
  166. #if    defined(__TURBOC__) && defined(MSDOS)
  167. #define movblock(so,ss,do,ds,c)    movedata(ss,so,ds,do,c)
  168.  
  169. #else
  170.  
  171. /* General purpose function macros already defined in turbo C */
  172. #ifndef    min
  173. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  174. #endif
  175. #ifndef max
  176. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  177. #endif
  178. #ifdef    MSDOS
  179. #define MK_FP(seg,ofs)    ((void far *) \
  180.             (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  181. #endif
  182. #endif    /* __TURBOC __ */
  183.  
  184. #ifdef    AMIGA
  185. /* super kludge de WA3YMH */
  186. #ifndef    fileno
  187. #include <stdio.h>
  188. #endif
  189. #define fclose(fp)    amiga_fclose(fp)
  190. extern int amiga_fclose __ARGS((FILE *));
  191. extern FILE *tmpfile __ARGS((void));
  192.  
  193. extern char *sys_errlist[];
  194. extern int errno;
  195. #endif
  196.  
  197. /* Externals used by getopt */
  198. extern int optind;
  199. extern char *optarg;
  200.  
  201. /* Threshold setting on available memory */
  202. extern int32 Memthresh;
  203.  
  204. /* System clock - count of ticks since startup */
  205. extern int32 Clock;
  206. extern int32 currtime;
  207.  
  208. extern char uploadstatus;
  209. extern unsigned char Nrows, Ncols;
  210.  
  211. /* Various useful standard error messages */
  212. extern char *Hostname;
  213. extern char Badhost[];
  214. extern char Nospace[];
  215. extern char Notval[];
  216. extern char Version[];
  217. extern char Badif[];
  218. extern char Badax[];
  219. extern char Nosocket[];
  220. extern char Nosess[];
  221. extern char Noipaddr[];
  222.  
  223. /* Your system's end-of-line convention */
  224. extern char Eol[];
  225.  
  226. extern struct ax25_cb;
  227. extern struct dirsort;
  228. extern struct iface;
  229. extern struct ip;
  230. extern struct mbx;
  231. extern struct mbuf;
  232. extern struct nr4cb;
  233. extern struct session;
  234. extern struct slip;
  235.  
  236. #  ifndef MDEBUG
  237.       void *mxalloc(unsigned nb);
  238.       void *mxallocw(unsigned nb);
  239.       void *cxalloc(unsigned nelem,unsigned size);
  240.       void *cxallocw(unsigned nelem,unsigned size);
  241.       void xfree(void *adr);
  242.       char *strxdup(const char *s);
  243. #else
  244.       void *mxalloc(char *file,unsigned line,unsigned nb);
  245.       void *mxallocw(char *file,unsigned line,unsigned nb);
  246.       void *cxalloc(char *file,unsigned line,unsigned nelem,unsigned size);
  247.       void *cxallocw(char *file,unsigned line,unsigned nelem,unsigned size);
  248.       void xfree(char *file,unsigned line,void *adr);
  249.       char *strxdup(char *file,unsigned line,const char *s);
  250. #     ifndef __ALLOC_C
  251. #        define mxalloc(nb) mxalloc(__FILE__,__LINE__,nb)
  252. #        define mxallocw(nb) mxallocw(__FILE__,__LINE__,nb)
  253. #        define cxalloc(elem,nb) cxalloc(__FILE__,__LINE__,elem,nb)
  254. #        define cxallocw(elem,nb) cxallocw(__FILE__,__LINE__,elem,nb)
  255. #        define xfree(blk) xfree(__FILE__,__LINE__,blk)
  256. #        define strxdup(s) strxdup(__FILE__,__LINE__,s)
  257. #     endif __ALLOC_C
  258. #   endif
  259.  
  260. #endif  /* _GLOBAL_H */
  261.  
  262.